<?php
namespace app\common\validate;

use think\Validate;

class ProductValidate extends Validate{

    protected $rule = [
        'name'=>'require',    //名称可以相同 因为有分组
        'cat'=>'number',
        'price'=>'require|float'
    ];

    protected $message = [
        'name.require'=>'产品名字必填',
        'cat.number'=>'操作错误',
        'price.require'=>'价格必填',
        'price.float'=>'价格必须为数字',
    ];

    protected $scene = [
        'add' => ['name','cat','price'],
        'edit' => ['name','cat','price'],
    ];
}